<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>提交论文审批</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<%@ include file="/module/orderField.jsp"%>
	<script type="text/javascript" src="${basePath}/js/jquery.Huploadify.js"></script>
	<link href="${basePath}/css/Huploadify.css" rel="stylesheet">
	<style>
	table label.error {
		margin-left: 5px;
		width: auto;
		display: inline;
		color: red;
	}
	.textat {text-align: center;}
	</style>
	<script type="text/javascript">
        //图片上传
        var file_path = "prefix";
        var file_path_one = null;
        var fileMap = new Array();
        $(function(){
            var up = $('#uploadadd').Huploadify({
                auto:false,
                fileTypeExts:'*.*',
                multi:true,
                formData:{key:123456,key2:'vvvv'},
                fileSizeLimit:99999999999,
                showUploadedPercent:true,
                showUploadedSize:true,
                removeTimeout:9999999,
                uploader : '${basePath}/teacherThesis/source_upload',
                onUploadStart:function(file){
                    console.log(file.name+'开始上传');
                },
                onInit:function(obj){
                    console.log('初始化');
                    console.log(obj);
                },
                onUploadComplete:function(file,data){
                    debugger;
                    var fi = $.parseJSON(data);
                    //文件名称
                    var filename = fi.filename;
                    //生成后的文件名
                    var sysFilepath = fi.sysfilepath;
                    //文件路径
                    var filepath = fi.filepath;
                    file_path_one = filename + "," + filepath;
                    file_path = file_path+"|"+filepath;
                    up.filePath=file_path_one;
                    //保存到集合
                    fileMap[file.index]=new Array(file_path_one);
                },
                onCancel:function(file){
                    console.log(file.name+'删除成功');
                },
                onClearQueue:function(queueItemCount){
                    console.log('有'+queueItemCount+'个文件被删除了');
                },
                onDestroy:function(){
                    console.log('destroyed!');
                },
                onSelect:function(file){
                    console.log(file.name+'加入上传队列');
                },
                onQueueComplete:function(queueData){
                    console.log('队列中的文件全部上传完成',queueData);
                }
            });
        });

        //删除图片
        function deletefile(id){
            var url = "${basePath}/teacherThesis/deletefile";
            $.ajax({
                type : "POST",
                url : url,
                dataType:"json",
                data:{
                    filepath : id
                },
                success : function(data) {
                    if(data.success == "0000"){
                        alert("删除数据成功！");
                        var file_name = id.split(",")[0];
                        $("#"+file_name+"_hr").parent().parent().remove();
                    }else{
                        alert("未写入数据库的文件没有删除！请联系管理员！");
                    }
                }
            })
        }
	</script>
</head>
<body>

	
	<form action="#" name="Form" id="Form" method="post">
		<input  type="hidden" id="lwid" name="lwid" value="${teacherThesis.lwid}"/>
		<table cellpadding="0" cellspacing="0" border="0" class="table-border" width="50%">
			<tr>
				<td class="table-header" colspan="4">提交论文审批</td>
			</tr>
			<tr>
				<td class="table-titleTD"><font
						style="color: red;">*</font>论文题目：</td>
				<td class="table-contentTD">
					${teacherThesis.subject }</td>
				<td class="table-titleTD">论文时间：</td>
				<td class="table-contentTD">
					${teacherThesis.lwsj }</td>
			</tr>
			<tr>
				<td class="table-titleTD">提交人：</td>
				<td class="table-contentTD">
					${entity.creatorName}
				</td>
				<td class="table-titleTD">提交日期：</td>
				<td class="table-contentTD">
					${entity.createTime}
				</td>
			</tr>
			<tr>
				<td class="table-titleTD">备注：</td>
				<td class="table-contentTD" colspan="3">
					${teacherThesis.remark}
				</td>
			</tr>
			<tr>
				<td class="table-titleTD">附件：</td>
				<td class="table-contentTD" colspan="3">
					<table>
						<c:forEach items="${dataList}" var="datalist" varStatus="index">
							<tr>
								<td>
									[文件] ${datalist.filename}
								</td>
								<td>
									<a href="${basePath}/DownLoadFileServlet?filename=${datalist.filename}&filepath=${datalist.filepath}">下载</a>
									<button id="${datalist.gid}_hr" type="button"  onclick="deleteByPK('${datalist.gid}');">删除</button>
								</td>
							</tr>
						</c:forEach>
					</table>
				</td>
			</tr>
		</table>
		
		
		<table cellpadding="0" cellspacing="0" border="0" class="table-border" width="50%">
			<tr>
				<td class="table-header" colspan="4">审核结果</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width:15%;"><font
						style="color: red;">*</font>审批人：</td>
				<td class="table-contentTD" style="width:35%;">
					${entity.creatorName}</td>
				<td class="table-titleTD" style="width:15%;">审批时间：</td>
				<td class="table-contentTD" style="width:35%;">
					${entity.createTime}
				</td>
			</tr>
			<tr>
				<td class="table-titleTD">推荐结果：</td>
				<td class="table-contentTD">
				${teacherThesis.tjjg}
					<input  type="hidden" id="tjjg" name="tjjg" value="${teacherThesis.tjjg}"/>
				</td>
				<td class="table-titleTD">获奖级别：</td>
				<td class="table-contentTD">
					${teacherThesis.hjjb}
					<input  type="hidden" id="hjjb" name="hjjb" value="${teacherThesis.hjjb}"/>
				</td>
			</tr>
			<tr>
				<td class="table-titleTD"><font
						style="color: red;">*</font>审批意见：</td>
				<td class="table-contentTD" colspan="3">
					<textarea rows="5" cols="50" name="auditSuggestion" id="auditSuggestion" maxlength="2000" class="required"></textarea>
				</td>
			</tr>
		</table>

	</form>
	<br />
	
	<table cellpadding="1" cellspacing="1" border="0" align="left">
	<tr>
		<td><input id="btnSave" class="inputButton textat"  autocomplete="off" value="推荐" /></td>
		<td><input id="btnSaveContinue" class="inputButton textat" autocomplete="off" value="不推荐" /></td>
		<td id="tdHid" style="display: none;"><input id="btnopen" class="inputButton textat" autocomplete="off" value="设置获奖级别" /></td>
		<td><input id="returnBut" class="inputButton textat" autocomplete="off" value="返回"/></td>
	</tr>
	</table>
	<div id="div1"
		style="display: none; text-align: center; padding-top: 35px; height: 100px;">
		<!-- <div style="margin-top: 0px;"> -->
			<table cellpadding="0" cellspacing="0" border="0" align="center">
				<tr>
					<td class="table-titleTD">获奖级别:</td>
					<td class="table-contentTD">
					<input type="number" id="jibie" name="jibie" value="" 
					maxlength="50" 
						class=" required" />&nbsp&nbsp;</td>
				</tr>
			</table>
		</div>
        	
	<script>
		
	     
	
		$(document).ready(function() {
			
			  //设置获奖级别弹出层
	        $("#div1").dialog({
	            width : '350px',
	            height : 'auto',
	            bgiframe : true,
	            modal : true,
	            draggable : true,
	            resizable : false,
	            title : '设置获奖级别',
	            autoOpen : false,
	            buttons : {
	                '取消' : function() {
	                    $(this).dialog('close');
	                },
	                '确定' : function() {
                    	var jibie = $('#jibie').val();
						$("#hjjb").attr("value",jibie);
                        //$("#div1").dialog('close');

						validataSave();
	                }
	            }
	        });

			  //点击弹出层
	        $("#btnopen").click(function(){
	            $('#div1').dialog('open');
	        });

			var _form=$("#Form").validate();
			//推荐
			$("#btnSave").click(function() {
				if(_form.form()) {
					$("#tjjg").attr("value","推荐");
					document.getElementById("tdHid").style.display = "inline";
				}
			});
			//不推荐
			$("#btnSaveContinue").click(function() {
				if(_form.form()){
					$("#tjjg").attr("value","不推荐");
				  	validataSaveContinue();
				}
			});
			
			function validataSave(){
			   	document.Form.action ="${basePath}/teacherThesisAuditing/save?action=1";
				document.Form.submit();
			}
			function validataSaveContinue(){
				document.Form.action ="${basePath}/teacherThesisAuditing/save?action=2";
				document.Form.submit();
			}
			$("#returnBut").click(function() {
			   	window.location.href='${basePath}/teacherThesisAuditing/index';
			});
		});
	   	if("${msg}"!=""){
		   	layer.alert("${msg}", {icon: 6});
	  	}
	</script>
</body>
</html>